import sessionStorage from "./sessionStorage";
let sessionStrageKey = "TardeDictionary";
// 设置新的数据字典
export const setDictionaryList = (value) => {
  sessionStorage.save({
    encrypt: false,
    key: sessionStrageKey,
    value,
  });
};
// 获取数据字典
export const getDictionaryValues = () => {
  let discutionary = sessionStorage.get(sessionStrageKey);
  console.log(discutionary);
};
export const getDictionaryList = () => {
  let discutionary = sessionStorage.get(sessionStrageKey);
  return discutionary;
};
export const get = (discutionary) => {
  let discutionaryList = sessionStorage.get(sessionStrageKey);
  let findData = discutionaryList.find((item) => item.name == discutionary);
  return findData.values;
};
export const extend = (discutionary, value) => {
  try {
      let l = sessionStorage.get(sessionStrageKey);
  let f = l.find((item) => item.name == discutionary);
  let g = f.values.find(i => i.value == value)
  return g.label;
  } catch (error) {
    return null
  }

};

export default {
  setDictionaryList,
  getDictionaryValues,
  getDictionaryList,
  get,
  extend,
};
